package framework.objects;

import framework.managers.MathManager;


public abstract class ObjectFactory<T extends DynamicGameObject> {

	protected int timeForCreation;
	protected int maxDelay;
	protected DynamicGameObjectsGroup<T> group;
	
	public ObjectFactory(DynamicGameObjectsGroup<T> group, int maxDely) {
		this.maxDelay = maxDely;
		this.group = group;
		initTimeForCreation();
	}
	
	protected void initTimeForCreation() {
		timeForCreation = MathManager.getRandom().nextInt(maxDelay);
	}

	public void createObject(float deltaTime) {
		timeForCreation -= (int) (deltaTime * 1000);
		if (timeForCreation < 0) {
			doCreation();
			initTimeForCreation();
		}
	}

	protected abstract void doCreation();
	
}
